# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Jelle van der Waa <jelle@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Vesa Kaihlavirta <vegai@iki.fi>
# Contributor: orbisvicis <gmail.com>

pkgname=xmonad-contrib
pkgver=0.17.1
pkgrel=117
pkgdesc='Community-maintained extensions for xmonad'
url='https://xmonad.org/'
arch=('loong64' 'x86_64')
license=('BSD')
depends=('ghc-libs' 'xmonad' 'haskell-x11' 'haskell-x11-xft' 'haskell-utf8-string' 'haskell-random')
makedepends=('ghc' 'haskell-quickcheck' 'haskell-hspec')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/xmonad/xmonad-contrib/archive/v${pkgver}.tar.gz)
sha512sums=('a1e5fc989ed04b79be32780a8246b8b0eda313bf910a2b8b0cf437d8843a8fcbf61526789ee32c3359ca2d48a858fe571356a0d666d8d992f01427f06e16e6b5')

build() {
  cd ${pkgname}-${pkgver}
  runhaskell Setup.lhs configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
             --prefix=/usr -fuse_xft --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
             --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname --enable-tests
  runhaskell Setup build $MAKEFLAGS
  runhaskell Setup register --gen-script
  runhaskell Setup unregister --gen-script
  sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
  sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
  cd ${pkgname}-${pkgver}
  runhaskell Setup test --show-details=direct
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm 744 register.sh   "${pkgdir}/usr/share/haskell/register/${pkgname}.sh"
  install -Dm 744 unregister.sh "${pkgdir}/usr/share/haskell/unregister/${pkgname}.sh"
  runhaskell Setup.lhs copy --destdir="${pkgdir}"
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
}
